<!doctype html>
<html lang="en" class="fixed">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>教师列表</title>
    <link rel="apple-touch-icon" sizes="120x120" href="favicon/apple-icon-120x120.png">
    <link rel="icon" type="image/png" sizes="192x192" href="favicon/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/animate.css/animate.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.css')) ?>">
    <link rel="stylesheet"
          href="<?php xcho(loadSource('/assets/plugins/data-table/media/css/dataTables.bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/style.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/layui/css/layui.css')) ?>" media="all">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/app.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
    <style type="text/css">
        .pagination{
            margin: 0;
        }
        ul,li,ol,li{
            list-style: none;
        }
        body{
            background: #f4f4f4;
        }
    </style>
</head>
<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>
<form action="<?php xcho($sSearchAction); ?>" method="get" enctype="application/x-www-form-urlencoded">
    <div class="class-box">
        <div class="class-box-head">
            <div class="class-box-title">
                <h3 class="col-md-8">教师列表</h3>
                <div class="input-group col-md-4">
                   <input type="text" class="form-control" name="keyword" value="<?php xcho($aSearch['keyword']); ?>" autocomplete="off" placeholder="搜索教师名" />
                </div>
            </div>
        </div>
        <div class="class-box-body">
            <div class="col-xs-6 col-sm-3 form-container form-inline form-container-noborder">
                <div class="form-group">
                    <label>科目：</label>
                    <select class="form-control" name="subject">
                        <option value=""<?php if($aSearch['tsubject']==''){ ?> selected="selected"<?php } ?>>请选择</option>
                        <?php foreach($aSubjects as $aSubject){ ?>
                        <option value="<?php xcho($aSubject['dict_value']); ?>"<?php if($aSearch['tsubject']==$aSubject['dict_value']){ ?> selected="selected"<?php } ?>><?php xcho($aSubject['cn_name']); ?></option>
                        <?php } ?>
                    </select>
                </div>
                <div class="form-group">
                    <label for="">性别：</label>
                    <select class="form-control" name="sex">
                        <option value=""<?php if($aSearch['sex']==''){ ?> selected="selected"<?php } ?>>全部</option>
                        <?php foreach($aSexes as $aSex){ ?>
                        <option value="<?php xcho($aSex['dict_value']); ?>"<?php if($aSearch['sex']==$aSex['dict_value']){ ?> selected="selected"<?php } ?>><?php xcho($aSex['cn_name']); ?></option>
                        <?php } ?>
                    </select>
                </div>
                <div class="form-group">
                    <label for="">级别：</label>
                    <select class="form-control" name="level">
                        <option value=""<?php if($aSearch['level']==''){ ?> selected="selected"<?php } ?>>全部</option>
                        <?php foreach($aLevels as $aLevel){ ?>
                        <option value="<?php xcho($aLevel['dict_value']); ?>"<?php if($aSearch['level']==$aLevel['dict_value']){ ?> selected="selected"<?php } ?>><?php xcho($aLevel['cn_name']); ?></option>
                        <?php } ?>
                    </select>
                </div>
                <div class="form-group">
                    <label for="">教育水平：</label>
                    <select class="form-control" name="degree">
                        <option value=""<?php if($aSearch['degree']==''){ ?> selected="selected"<?php } ?>>全部</option>
                        <?php foreach($aDegrees as $aDegree){ ?>
                        <option value="<?php xcho($aDegree['dict_value']); ?>"<?php if($aSearch['degree']==$aDegree['dict_value']){ ?> selected="selected"<?php } ?>><?php xcho($aDegree['cn_name']); ?></option>
                        <?php } ?>
                    </select>
                </div>
                <div class="form-group">
                    <label for="">状态：</label>
                    <select class="form-control" name="job_status">
                        <option value=""<?php if($aSearch['job_status']==''){ ?> selected="selected"<?php } ?>>全部</option>
                        <?php foreach($aJobStatuses as $aJobStatus){ ?>
                        <option value="<?php xcho($aJobStatus['dict_value']); ?>"<?php if($aSearch['job_status']==$aJobStatus['dict_value']){ ?> selected="selected"<?php } ?>><?php xcho($aJobStatus['cn_name']); ?></option>
                        <?php } ?>
                    </select>
                </div>
                <div class="btns-group">
                    <input type="submit" class="btn btn-primary edit" value="确定" />
                </div>
            </div>
        </div>
    </div>
    
     
    <div class="class-box">
        <div class="class-box-head">
            <div class="class-box-title">
                <h3>列表</h3>
                <div class="class-box-tools">
                    <a class="btn btn-default" id="excel" url="<?php xcho($sExcel) ?>">导出</a>
                    <a class="btn btn-primary" href="<?php xcho($sAddUrl) ?>" >添加老师</a>
                </div>
            </div>
        </div>
        <div class="class-box-body">
            <table class="layui-form table table-bordered table-hover table table-bordered table-striped">
                <tr>
                    <th><input type="checkbox" lay-filter="allChoose" lay-skin="primary" name="checkAll"></th>
                    <th><?php if($iOrderBy==1){ ?><a href="<?php xcho($aOrderURLs[2]); ?>">姓名</a><?php }else{ ?><a href="<?php xcho($aOrderURLs[1]);?>">姓名</a><?php } ?></th>
                    <th>科目</th>
                    <th>级别</th>
                    <th>最大同时授课</th>
                    <th>天王星ID</th>
                    <th>性别</th>
                    <th>教育水平</th>
                    <th>QQ</th>
                    <th>手机号</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                <?php foreach($aOrderTeachers as $aTeacher){ ?>
                <tr>
                    <td><input type="checkbox" lay-filter="itemChoose" name="ck"
                               lay-skin="primary" id="<?php xcho($aTeacher['id']) ?>"></td>
                    <td><a href="<?php xcho($aTeacher['info_url']) ?>" ><?php xcho($aTeacher['tname']); ?></a></td>
                    <td><?php xcho(join(',',$aTeacher['tsubject_str'])); ?></td>
                    <td><?php xcho($aTeacher['level_str']); ?></td>
                    <td><?php xcho($aTeacher['max_simul']); ?></td>
                    <td><?php xcho($aTeacher['twx_id']); ?></td>
                    <td><?php xcho($aTeacher['sex_str']); ?></td>
                    <td><?php xcho($aTeacher['degree_str']); ?></td>
                    <td><?php xcho($aTeacher['qq']); ?></td>
                    <td><?php xcho($aTeacher['cellphone']); ?></td>
                    <td><?php xcho($aTeacher['job_status_str']); ?></td>
                    <td>
            <!--            <a class="layui-btn layui-btn-mini" href="--><?php //xcho($aTeacher['edit_url']); ?><!--" target="_blank">编辑</a>-->
                        <a class="btn btn-primary" href="<?php xcho($aTeacher['edit_url']) ?>" >编辑</a>
                        <a class="btn btn-sub layui-btn-danger" tid="<?php xcho($aTeacher['id']) ?>">删除</a>
                    </td>
                </tr>
                <?php } ?>
            </table>
        </div>
        <div class="row pagination-wrap">
            <div class="col-sm-6">
                <ul class="pagination">
                    <?php xchoHtml($aOTeachers->render()); ?>
                </ul>
            </div>
        </div>
    </div>
</form>

<input type="hidden" name="delteacher" value="<?php xcho($delteacher) ?>">

<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/jquery.dataTables.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/dataTables.bootstrap.min.js')) ?>"></script>
<script
    src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/dataTables.responsive.min.js')) ?>"></script>
<script
    src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/responsive.bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.core.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layui/layui.all.js')) ?>" charset="utf-8"></script>
<script type="text/javascript" src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.excheck.js')) ?>"></script>
<script type="text/javascript" src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.exedit.js')) ?>"></script>
<script>
    $(function () {
        $(".layui-btn-danger").on("click",function () {
            if(confirm("确定删除本条数据吗？")){
                var del_url=$("input[name='delteacher']").val();
                var tid=$(this).attr('tid');
                $.ajax({
                    url:del_url,
                    type:'post',
                    dataType:'json',
                    data:{id:tid},
                    success: function (data) {
                        if (data.success == 1) {
                            layer.alert("删除成功!", {
                                skin: 'layui-layer-molv'
                            }, function () {
                                location.reload();
                            })
                        } else {
                            layer.alert(data.msg, {
                                skin: 'layui-layer-molv'
                            }, function () {
                                location.reload();
                            })
                        }
                    },
                    complete: function () {
                    },
                    error: function () {
                    }
                })

            }
        })
    });

    layui.use(['form'], function(){
        var form = layui.form;
        form.on('checkbox(allChoose)', function (data) {
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function (index, item) {
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
        form.on('checkbox(itemChoose)', function (data) {
            var sib = $(data.elem).parents('table').find('tbody input[type="checkbox"]:checked').length;
            var total = $(data.elem).parents('table').find('tbody input[type="checkbox"]').length;
            if (sib == total) {
                $(data.elem).parents('table').find('thead input[type="checkbox"]').prop("checked", true);
                form.render();
            } else {
                $(data.elem).parents('table').find('thead input[type="checkbox"]').prop("checked", false);
                form.render();
            }
        });
    });

   /* $("input[name='checkAll']").on('click',function () {

    })*/
    $("#excel").on('click', function () {
        var aIDs = [];
        $('input[name="ck"]:checked').each(function () {
            aIDs.push($(this).attr('id'));
        });
        if (aIDs.length == 0) {
            layer.alert("至少选择一项");
        } else {
            $.ajax({
                url: $(this).attr('url'),
                data: {
                    ids: aIDs,
                },
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if (data.success == 1) {
                        window.open(data.data);
                    } else {

                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
        }
    });

</script>
    <?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>

<button id="top" style="height: 50px;width: 50px;"></button></body>
</html>